package com.gg.user.gguser.controller;

import com.gg.user.gguser.service.GgLoginService;
import com.gg.user.gguser.service.GgItemsOnlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@CrossOrigin // 注解方式
@RestController
// @RequestMapping("/login")
public class GgLogoController {

    @Autowired
    private GgLoginService ggLoginService;

    @Autowired
    private GgItemsOnlyService GgItemsOnlyService;

    /**
     * 用户登陆
     */
    @PostMapping("/login")
    public Object login(HttpServletResponse response, HttpServletRequest request, String name, String password){
        return ggLoginService.login(response,request,name,password);
    }

    /**
     * 注册
     */
    @GetMapping("/register")
    public Object register(HttpServletResponse response, HttpServletRequest request, String name, String password,String ypassword,String mailbox){
        return ggLoginService.register(response,request,name,password);
    }

    /**
     * 退出登陆
     */
    @PostMapping("/signOut")
    public Object signOut(HttpServletResponse response, HttpServletRequest request){
        return ggLoginService.signOut(response,request);
    }

    @RequestMapping("/logo/three")
    public Object logoThree(HttpServletResponse response, HttpServletRequest request) throws Exception{
        return null;
    }

    @GetMapping("demo")
    public Object demo(HttpServletResponse response, HttpServletRequest request,String ggIoType) throws Exception{
        return GgItemsOnlyService.judgeItemsOnly(response,request,ggIoType);
    }
}
